﻿nvModule.controller("eventController", function ($scope, EventsService) {
    EventsService.getNhanVienTalks().then(function (talks) {
        $scope.talks = talks;
        
        $scope.totalItems = $scope.talks.length;
        $scope.itemsPerPage = 5
        $scope.currentPage = 1;
        $scope.maxSize = 5;
        $scope.bigTotalItems = 175;
        $scope.bigCurrentPage = 1;
        console.log("$scope.talks.length " + $scope.talks.length);
        $scope.pageCount = function () {
            return Math.ceil($scope.talks.length / $scope.itemsPerPage);
        };
        $scope.$watch('currentPage + itemsPerPage', function () {
            var begin = (($scope.currentPage - 1) * $scope.itemsPerPage),
                end = begin + $scope.itemsPerPage;

            $scope.filteredtalks = $scope.talks.slice(begin, end);
        });


    }, function ()
    { alert('error while fetching talks from server') })
});